package cn.csg.ams.collect2.poptopics.dao;

import cn.csg.ams.collect2.poptopics.entity.ao.MkPrPfOutageBlackListAO;
import cn.csg.ams.collect2.poptopics.entity.bo.MkPrPfOutageBlackListBO;
import cn.csg.ams.collect2.poptopics.entity.vo.MkPrPfOutageBlackListVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author: zhanggang
 * @ClassName: MkPrPfOutageBlackListDao
 * @date: 2023-12-27 10:58:50
 * @Description: 停电告警黑名单(mk_pr_pf_outage_black_list)表数据库访问层
 */
public interface MkPrPfOutageBlackListDao extends BaseMapper<MkPrPfOutageBlackListBO> {

    /**
     * @Title:getMkPrPfOutageBlackListListPage
     * @Description:查询指定行数据
     * @date: 2023-12-27 10:58:50
     * @params: mkPrPfOutageBlackListAo 查询条件
     * @return：List<MkPrPfOutageBlackListVO>
     * @throw：
     */
    List<MkPrPfOutageBlackListVO> getMkPrPfOutageBlackListListPage(MkPrPfOutageBlackListAO mkPrPfOutageBlackListAo);

    /**
     * @Title:getMkPrPfOutageBlackListTotal
     * @Description:统计总行数
     * @date: 2023-12-27 10:58:50
     * @params: mkPrPfOutageBlackListAo 查询条件
     * @return：int
     * @throw：
     */
    int getMkPrPfOutageBlackListTotal(MkPrPfOutageBlackListAO mkPrPfOutageBlackListAo);

    /**
     * 根据运行电能表标识查询是否在黑名单中
     *
     * @param runMeterId 运行电能表标识
     * @return boolean
     */
    @Select("select count(*) > 0 from mk_pr_pf_outage_black_list where run_meter_id = #{runMeterId}")
    boolean checkBlackList(String runMeterId);

    /**
     * 添加黑名单
     *
     * @param runMeterId 运行电能表标识
     * @param runTermId  运行终端标识
     */
    @Insert("INSERT INTO mk_pr_pf_outage_black_list (run_meter_id, run_term_id, join_date) VALUES(#{runMeterId}, #{runTermId}, now());")
    void insertBlackList(@Param("runMeterId") String runMeterId, @Param("runTermId") String runTermId);

    Long checkTerm(@Param("alarmTime") Date alarmTime, @Param("runTermId") String runTermId);

    Long checkUser(@Param("alarmTime") Date alarmTime, @Param("elecCustNo") String elecCustNo);

    /**
     * 插入智能运维工单
     *
     * @param runMeterId 运行电能表标识
     */
    void insertWorkOrder(@Param("runMeterId") String runMeterId, @Param("dataPart") String dataPart);
}
